package com.example.ordersys.controller;

import com.example.ordersys.mapper.DishMapper;
import com.example.ordersys.model.Dish;
import com.example.ordersys.tools.ResponseBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/dish")
@RestController
public class DishController {
    @Resource
    private DishMapper dishMapper;

    /**
     * 菜品列表
     * @return
     */
    @RequestMapping("/list")
    public ResponseBody<List<Dish>> getList() {
        List<Dish> data = dishMapper.getList();
        return new ResponseBody<>(0,"",data);
    }
    /**
     * 删除菜品
     */
    @RequestMapping("/delete")
    public ResponseBody<Integer> delete(int id){
        int data = dishMapper.deleteById(id);
        return new ResponseBody<>(0,"",data);
    }
    /**
     * 增加菜品
     */
    @RequestMapping("/add")
    public ResponseBody<Integer> add(Dish dish){
        int data = 0;
        data = dishMapper.add(dish);
        return new ResponseBody<>(0,"",data);
    }
}
